package com.rent.rent_back_end.controller;

import com.rent.rent_back_end.common.Result;
import com.rent.rent_back_end.domain.Home;
import com.rent.rent_back_end.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author LiDongqing
 * @since 2023-02-06
 * 获取房源信息
 */

@RestController
@CrossOrigin
@RequestMapping("/home")
public class HomeController {

    @Autowired
    HomeService homeService;

    /**
     * 根据房源地址模糊查询
     * @return Result
     */
    @GetMapping()
    public Result getAllHome(@RequestBody Map<String, Object> map) {
        String homeAddress = map.get("homeAddress").toString();
        List<Home> record = homeService.getAllHome(homeAddress);
        return new Result(200, record, "获取房源成功");
    }
}
